
#include "BalloonWindow.h"


BEGIN_EVENT_TABLE(BalloonWindow, wxDialog)
    EVT_TIMER(-1, BalloonWindow::OnTimer)
    EVT_LEFT_DOWN(BalloonWindow::OnClick)
    EVT_RIGHT_DOWN(BalloonWindow::OnClick)
END_EVENT_TABLE()

BalloonWindow::BalloonWindow(wxWindow* parent,  const wxString& title, const wxString& message)
        :wxDialog(parent,-1,title,wxDefaultPosition,wxDefaultSize,wxSIMPLE_BORDER | wxWS_EX_TRANSIENT)
{
    m_timer = new wxTimer(this);

    SetBackgroundColour(textBackground);

    int screenWidth = wxSystemSettings::GetMetric(wxSYS_SCREEN_X);
    int screenHeight = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y);

    x = screenWidth-400;
    y = screenHeight-400;

    Move(x, y);

    Show();

    m_timer->Start(40);
}

BalloonWindow::~BalloonWindow()
{
    delete m_timer;
}

void BalloonWindow::OnClick(wxMouseEvent& e)
{
    Destroy();
}

void BalloonWindow::OnTimer(wxTimerEvent& e)
{
    y-=10;
    if(y<=0)
        Destroy();
    else
        Move(x, y);

}

